package com.xique.park.bean.transform.web.garageLaneDev;

import com.xique.park.bean.domain.ParkLane;
import com.xique.park.bean.request.web.garageLaneDev.board.LedSetRequest;
import com.xique.park.bean.request.web.garageLaneDev.board.VoiceSetRequest;
import com.xique.park.bean.vo.web.garageLaneDeviceTree.LedConfigVo;
import com.xique.park.bean.vo.web.garageLaneDeviceTree.VoiceConfigVo;

/**
 * 控制板相关实体转换类
 *
 * @author: xique
 */
public class BoardTransform {

    /**
     * parkLane转化为LedConfigVo
     */
    public static LedConfigVo transformLedConfigVo(ParkLane parkLane) {
        LedConfigVo ledConfigVo = new LedConfigVo();
        if (null != parkLane) {
            ledConfigVo.setLaneId(parkLane.getId());
            ledConfigVo.setIsDisplay(parkLane.getIsLed());
            ledConfigVo.setRows(parkLane.getMonitorRows());
            /*有车时*/
            ledConfigVo.setRow1(parkLane.getRowCarOne());
            ledConfigVo.setRow1Def(parkLane.getRowCarContentOne());
            ledConfigVo.setRow2(parkLane.getRowCarTwo());
            ledConfigVo.setRow2Def(parkLane.getRowCarContentTwo());
            ledConfigVo.setRow3(parkLane.getRowCarThree());
            ledConfigVo.setRow3Def(parkLane.getRowCarContentThree());
            ledConfigVo.setRow4(parkLane.getRowCarFour());
            ledConfigVo.setRow4Def(parkLane.getRowCarContentFour());
            /*无车时*/
            ledConfigVo.setRow1Free(parkLane.getRowNoCarOne());
            ledConfigVo.setRow1FreeDef(parkLane.getRowNoCarContentOne());
            ledConfigVo.setRow2Free(parkLane.getRowNoCarTwo());
            ledConfigVo.setRow2FreeDef(parkLane.getRowNoCarContentTwo());
            ledConfigVo.setRow3Free(parkLane.getRowNoCarThree());
            ledConfigVo.setRow3FreeDef(parkLane.getRowNoCarContentThree());
            ledConfigVo.setRow4Free(parkLane.getRowNoCarFour());
            ledConfigVo.setRow4FreeDef(parkLane.getRowNoCarContentFour());
        }
        return ledConfigVo;
    }

    /**
     * parkLane转化为VoiceConfigVo
     */
    public static VoiceConfigVo transformVoiceConfigVo(ParkLane parkLane) {
        VoiceConfigVo voiceConfigVo = new VoiceConfigVo();
        if (null != parkLane) {
            voiceConfigVo.setLaneId(parkLane.getId());
            voiceConfigVo.setLowDuration(parkLane.getLowVoiceTime());
            voiceConfigVo.setLowValue(parkLane.getLowVoiceSound());
            voiceConfigVo.setHighDuration(parkLane.getHighVoiceTime());
            voiceConfigVo.setHighValue(parkLane.getHighVoiceSound());
        }
        return voiceConfigVo;
    }

    /**
     * 显示屏设置请求request转化为parkLane
     *
     * @param parkLane 数据库原来的通道
     */
    public static ParkLane transformLedSetRequest(ParkLane parkLane, LedSetRequest request) {
        if (null != parkLane) {
            parkLane.setId(request.getLaneId());
            parkLane.setMonitorRows(request.getRows());
            parkLane.setIsLed(request.getIsDisplay());
            /*有车时*/
            parkLane.setRowCarOne(request.getRow1());
            parkLane.setRowCarContentOne(request.getRow1Def());
            parkLane.setRowCarTwo(request.getRow2());
            parkLane.setRowCarContentTwo(request.getRow2Def());
            parkLane.setRowCarThree(request.getRow3());
            parkLane.setRowCarContentThree(request.getRow3Def());
            parkLane.setRowCarFour(request.getRow4());
            parkLane.setRowCarContentFour(request.getRow4Def());
            /*无车时*/
            parkLane.setRowNoCarOne(request.getRow1Free());
            parkLane.setRowNoCarContentOne(request.getRow1FreeDef());
            parkLane.setRowNoCarTwo(request.getRow2Free());
            parkLane.setRowNoCarContentTwo(request.getRow2FreeDef());
            parkLane.setRowNoCarThree(request.getRow3Free());
            parkLane.setRowNoCarContentThree(request.getRow3FreeDef());
            parkLane.setRowNoCarFour(request.getRow4Free());
            parkLane.setRowNoCarContentFour(request.getRow4FreeDef());
        }
        return parkLane;
    }

    /**
     * 音量设置请求request转化为parkLane
     */
    public static ParkLane transformVoiceSetRequest(VoiceSetRequest request) {
        ParkLane parkLane = new ParkLane();
        parkLane.setId(request.getLaneId());
        parkLane.setHighVoiceSound(request.getHighValue());
        parkLane.setHighVoiceTime(request.getHighDuration());
        parkLane.setLowVoiceSound(request.getLowValue());
        parkLane.setLowVoiceTime(request.getLowDuration());
        return parkLane;
    }
}
